<?php
/**
* 从数据库获取网站参数
* $Id$
*/

include_once('mysql_connection.php');  // 包含数据库连接文件

/**
* @param $mysql_connection object 数据库链接
* @return array $setting
*/
function get_setting($mysql_connection) {
	$query_setting = 'select * from `setting`';
	// start 取得数据库中的用户设置参数，并加入一个数组中，方便在其他页面随时调用
	$result_setting = $mysql_connection->query($query_setting);
	$num_setting = $result_setting->num_rows;
	$setting = array();
	for ($i=0; $i<$num_setting; $i+=1) {
		$row_setting = $result_setting->fetch_assoc();
		$name_setting = $row_setting['name'];
		$value_setting = $row_setting['value'];
		$setting[$name_setting] = $value_setting;
	}
	$query_root = 'select `Email` from `root`';
	$result_root = $mysql_connection->query($query_root);
	$email_root = $result_root->fetch_assoc();
	$email_root = $email_root['Email'];
	$setting['email_root']=$email_root;
	// end 取得数据库中的用户设置参数，并加入一个数组中，方便在其他网页随时调用
	return $setting;
}
$setting = array();
$setting = get_setting($mysql_connection);
?> 
